<!DOCTYPE html>
<html ng-app='app'>

<head>
  <meta charset="utf-8">
  <title translate="TITLE">Remember language (local storage)</title>
  <style>body { text-align: center; }</style>
</head>

<body ng-controller="ctrl">

  <p>
    <a href="#" ng-click="setLang('en_US')">English</a>
    |
    <a href="#" ng-click="setLang('ru_RU')">Русский</a>
  </p>

  <h1 translate>HEADER</h1>
  <h2 translate>SUBHEADER</h2>

<script src="../bower_components/angular/angular.js"></script>

<!--
  Note that you have to include this module, because if local storage is not available,
  translations module will fallback to the cookies storage
-->
<script src="../bower_components/angular-cookies/angular-cookies.js"></script>

<script src="../dist/angular-translate.js"></script>
<script src="../dist/angular-translate-storage-cookie/angular-translate-storage-cookie.js"></script>
<script src="../dist/angular-translate-storage-local/angular-translate-storage-local.js"></script>

<script>
// Note that to use the local storage you have to pass ngCookies dependency to your module,
// because if local storage is not available, module will fallback to the cookies storage
angular.module('app', ['pascalprecht.translate', 'ngCookies'])

.config(['$translateProvider', function($translateProvider){

  // Adding a translation table for the English language
  $translateProvider.translations('en_US', {
    "TITLE"     : "How to remember a language (local storage)",
    "HEADER"    : "Your application is able to remember a language between requests.",
    "SUBHEADER" : "To store the language you can use a local storage."
  });

  // Adding a translation table for the Russian language
  $translateProvider.translations('ru_RU', {
    "TITLE"     : "Как запомнить язык (local storage)",
    "HEADER"    : "Ваше приложение может запоминать язык между запросами.",
    "SUBHEADER" : "Для хранения языка Вы можете использовать локальное хранилище.",
  });

  // Tell the module what language to use by default
  $translateProvider.preferredLanguage('en_US');

  // Tell the module to store the language in the local storage
  $translateProvider.useLocalStorage();

}])

.controller('ctrl', ['$scope', '$translate', function($scope, $translate) {

  $scope.setLang = function(langKey) {
    // You can change the language during runtime
    $translate.use(langKey);
  };

}]);
</script>

</body>
</html>
